package com.xjtu.chapter08.thread;



/**
 * @author yjq
 * @version 1.0
 * @date 2021/8/29 17:59
 */
//由Thread派生出两个子线程Lamb类和Wolf类，在main()中分别创建两个子线程thr1和thr2
public class ThreadTest1 {
    public static void main(String[] args) {
        Lamb thr1 = new Lamb();
        thr1.start();//thr1启动
        Wolf thr2 = new Wolf();
        thr2.start();
        //主线程仍在进行
        for (int i = 0; i < 3; i++) {
            System.out.println("main thread is running");
        }
    }
}
class Lamb extends Thread{
    @Override
    public void run() {
        for (int i = 0; i <3 ; i++) {
            System.out.println("I am a happy lamb");
        }
    }
}
class Wolf extends Thread{
    @Override
    public void run() {
        for (int i = 0; i <3 ; i++) {
            System.out.println("I am a big bad wolf");
        }
    }
}